<?
	function gender($x){
		return strtolower($x) == 'male' ? 'M' : 'F';
	}
?>
	<?if($students AND !empty($students)):?>
		<div class="dataset">
		<?foreach($students as $dk => $dv):?>
			<?foreach($dv as $dvk => $dvv):?>
				<h3><?=strtoupper($dvk);?></h3>
				<div style="padding:0;margin:0;">
					<table class="table table-bordered">
					<thead>
						<tr>
							<th>ID No</th>
							<th>Block</th>
							<th>Student Name</th>
							<th>Gender</th>
							<th>Date/Time Enrolled</th>
							<th>Age</th>
							<th>Date of Birth</th>
							<th>Nationality</th>
							<th>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<?if(!empty($dvv['students'])):?>
							<?foreach($dvv['students'] as $dvvk => $dvvv):?>
							<?$stat = isset($dvvv->registrar_approved) ? $dvvv->registrar_approved == 0 ? '#f00;' : '' : '';?>
								<tr>
									<td><?=ucwords($dvvv->idno);?></td>
									<td class="for-block"><?=ucwords($dvvv->block_name);?></td>
									<td style="font-weight:bold;font-size:12px;">
										<a href="<?=site_url('profile/student/'.$dvvv->enrollment_id);?>" style="color:<?=$stat;?>" target="_blank"><?=ucwords(strtolower($dvvv->fullname));?></a>
									</td>
									<td><?=ucwords(gender($dvvv->gender));?></td>
									<td class="for-doc"><?=$dvvv->date_enrolled;?></td>
									<td><?=$dvvv->age;?></td>
									<td class="for-doc"><?=$dvvv->dob;?></td>
									<td><?=ucwords($dvvv->nationality);?></td>
									<td>
										<?if($delete):?>
										<a href="<?=site_url('search/del/'.__link($dvvv->enrollment_id).'/'.$url);?>" class="confirm btn btn-mini btn-danger" title="Are you sure you want to delete student {<?=ucwords(strtolower($dvvv->fullname));?>} ?"><i class="icon-remove"></i></a>
										<?endif;?>
									</td>
								</tr>
							<?endforeach;?>
							<?
								$male[] = $dvv['male_count'];
								$female[] = $dvv['female_count'];
							?>
								<tr class="total">
									<td colspan="9" style="text-align:center;word-spacing:10px;">
										<span style="margin:0 10px;word-spacing:10px;font-weight:bold;font-size:11px;">MALE:&nbsp;<?=$dvv['male_count'];?>&nbsp;&nbsp;</span>
										<span style="margin:0 10px;word-spacing:10px;font-weight:bold;font-size:11px;">FEMALE:&nbsp;<?=$dvv['female_count'];?>&nbsp;&nbsp;</span>
										<span style="margin:0 10px;word-spacing:10px;font-weight:bold;font-size:11px;">TOTAL:&nbsp;<?=$dvv['female_count'] + $dvv['male_count'];?></span>
									</td>
								</tr>
						<?else:?>
							<tr class="info">
								<td colspan="9" style="text-align:center;">No Students Found</td>
							</tr>
						<?endif;?>
					</tbody>
					</table>
				</div>
			<?endforeach;?>
		<?endforeach;?>
			</div>
			<table class="table">
			<tr class="info">
				<td colspan="9" style="text-align:center;word-spacing:10px;">
					<span style="word-spacing:10px;font-weight:bold;font-size:11px;">MALE:&nbsp;<?=array_sum($male);?>&nbsp;&nbsp;</span>
					<span style="word-spacing:10px;font-weight:bold;font-size:11px;">FEMALE:&nbsp;<?=array_sum($female);?>&nbsp;&nbsp;</span>
					<span style="word-spacing:10px;font-weight:bold;font-size:11px;">TOTAL:&nbsp;<?=array_sum($male) + array_sum($female);?></span>
				</td>
			</tr>
			</table>
	<?else:?>
		<tr class="info">
			<td colspan="9" style="text-align:center;">No Students Found</td>
		</tr>
	<?endif;?>
<script>$(document).ready(function(){
  var icons = {
      header: "ui-icon-circle-arrow-e",
      activeHeader: "ui-icon-circle-arrow-s"
    }
  $('.dataset').accordion({
    heightStyle: "content",
    icons:icons});
});</script>